package com.itheima.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

/**
 * @author 刘全
 * @date 2021/9/12
 */
@Component
@Aspect
public class Active {

    //@Pointcut("execution(* com.itheima.*.*Dao*.*(..))")
    private void pt(){}

    //@Around("pt()")
    public void method(ProceedingJoinPoint pjp) throws Throwable {
        Signature signature = pjp.getSignature();
        String className = signature.getDeclaringTypeName();
        String methodName = signature.getName();
        long start = System.currentTimeMillis();
        for (int i = 0; i < 10000; i++) {
            pjp.proceed();
        }
        long end = System.currentTimeMillis();
        System.out.println("save...."+className+"."+methodName+"=====>"+(end-start));
    }
}
